package com.city.controller.party;

import com.city.domain.party.PartyLesson;
import com.city.domain.party.PartyVideo;
import com.city.domain.pub.PubArticle;
import com.city.service.party.PartyLessonService;
import com.city.service.party.PartyVideoService;
import com.city.service.pub.PubArticleService;
import org.omg.CORBA.Object;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.util.List;
import java.util.Map;

/**
 *
 *
  *@author:WY
  *@date: 2018/7/16 9:39
  *@description:党建前台
 *
 *
 */


@Controller
@RequestMapping("/party/home")
public class PartyHomeController {


    @Autowired
    private PubArticleService pubArticleService;

    @Autowired
    private PartyLessonService lessonService;

    @Autowired
    private PartyVideoService videoService;
    /**
     * *
      *@author:WY
      *@date: 2018/7/16 13:04
      *@description:党建主页
     *
     * @param map
     * @return
     */
    @RequestMapping("/index")
    public String index(HttpSession session,
                        HttpServletResponse response,
                        HttpServletRequest request,
                        Map<String, java.lang.Object> map){

        List<PubArticle> preTime = pubArticleService.findPubArticlesByPre("实时动态");
//        request.setAttribute("ss",preTime);    //这种是在前台进行判断
        List<PubArticle> news = pubArticleService.findPubArticlesByPre("党建要闻");

        List<PubArticle> politics = pubArticleService.findPubArticlesByPre("政治思想建设");

        List<PubArticle> note = pubArticleService.findPubArticlesByPre("通知公告");

        //得到所有课程
        List<PartyLesson> lessons = lessonService.findByTimeSort();
//        lessons.get(0).
        map.put("lessons",lessons);

        map.put("preTime",preTime);
        map.put("news",news);
        map.put("politics",politics);
        map.put("note",note);
        return "/party/index";
    }
    /**
     * *
     *@author:WY
     *@date: 2018/7/16 13:04
     *@description:党建地图
     *
     * @param map
     * @return
     */

    @RequestMapping("/map")
    public String map(Map<String,java.lang.Object> map){
        return "/party/map";
    }

    /**
     * *
     *@author:WY
     *@date: 2018/7/16 13:04
     *@description:文章页
     *
     * @param map
     * @return
     */

    @RequestMapping("/more")
    public String more(Map<String,java.lang.Object> map){
        return "/party/more";
    }

    /**
     * *
     *@author:WY
     *@date: 2018/7/16 13:04
     *@description:新闻资讯
     *
     * @param map
     * @return
     */
    @RequestMapping("/news")
    public String news(Map<String,java.lang.Object> map){
        return "/party/news";
    }

    /**
     * *
     *@author:WY
     *@date: 2018/7/16 13:04
     *@description:在线教育
     *
     * @param map
     * @return
     */

    @RequestMapping("/education")
    public String education(Map<String,java.lang.Object> map){
        //得到所有课程
        List<PartyLesson> lessons = lessonService.findByTimeSort();
//        lessons.get(0).getPic()
        map.put("lessons",lessons);

        return "/party/education";
    }

    /**
     * *
     *@author:WY
     *@date: 2018/7/16 13:04
     *@description:党建服务
     *
     * @param map
     * @return
     */

    @RequestMapping("/service")
    public String service(Map<String,java.lang.Object> map){
        return "/party/service";
    }

    /**
     * *
     *@author:WY
     *@date: 2018/7/16 13:04
     *@description:组织关系转出
     *
     * @param map
     * @return
     */
    @RequestMapping("/change")
    public String changeParty(Map<String,java.lang.Object> map){
        return "/party/change";
    }

    /**
     * *
      *@author:WY
      *@date: 2018/7/16 14:03
      *@description:流动申请
     */
    @RequestMapping("/liudong")
    public String liudong(Map<String,java.lang.Object> map){

        return "/party/liudong";

    }
    /**
     *
      *@author:WY
      *@date: 2018/7/16 14:28
      *@description:流出申请
     *
     */
    @RequestMapping("/liuchu")
    public String liuchu(Map<String,java.lang.Object> map){


        return "/party/liuchu";
    }

    /**
     * *
      *@author:WY
      *@date: 2018/7/16 15:05
      *@description:入党申请
     *
     */
    @RequestMapping("/rdsq")
    public String rdsq(Map<String,java.lang.Object> map){
        return "/party/rdsq";
    }

    /**
     * *
      *@author:WY
      *@date: 2018/7/16 16:09
      *@description:12380举报
     *
     */
    @RequestMapping("/1230870")
    public String jubao(Map<String,java.lang.Object> map){
        return "/party/12380";
    }

    /**
     * *
      *@author:WY
      *@date: 2018/7/16 16:48
      *@description:举报查询
     *
     */
    @RequestMapping("/12380/search")
    public String jb_search(Map<String,java.lang.Object> map){
        return "/party/12380_search";
    }

    /**
     *
      *@author:WY
      *@date: 2018/7/16 19:13
      *@description:举报个人
     *
     */
    @RequestMapping("/12380/personal")
    public String jb_person(Map<String,java.lang.Object> map){
        return "/party/12380_jp";
    }
    /**
     * *
      *@author:WY
      *@date: 2018/7/16 19:29
      *@description:举报组织
     *
     */
    @RequestMapping("/12380/group")
    public String jb_group(){
        return "/party/12380_jg";
    }
    /**
     **
      *@author:WY
      *@date: 2018/7/16 19:47
      *@description:干部出国
     */
    @RequestMapping("/cadres_abroad")
    public String cadres_abroad(Map<String,java.lang.Object> map){
        return "/party/cadres_abroad";
    }

    /**
     **
      *@author:WY
      *@date: 2018/7/17 9:53
      *@description:出国查询
     *
     */
    @RequestMapping("/abroad_search")
    public String abroad_search(Map<String,java.lang.Object> map){
        return "/party/abroad_search";
    }

    /**
     * *
      *@author:WY
      *@date: 2018/7/17 15:48
      *@description:视频界面
     *
     */
    @RequestMapping("/vedio")
    public String vedio(Map<String,java.lang.Object> map,int id){

//        //通过课程id查询对应video
//        List<PartyVideo> videos = videoService.findByLessonId(id);
////        videos.get(0).getPic()
//        map.put("videos",videos);
        return "/party/vedio";
    }

    /**
     * *
      *@author:WY
      *@date: 2018/7/23 15:50
      *@description:文章界面
     */
    @RequestMapping("/article")
    public String article(){
        return "/party/more";
    }

    /**
     * @author  王宇
     * @date 2018/7/28
     * @description  实时动态
     */
    @RequestMapping("/realtimeArticle")
    public String realtime(Map<String,java.lang.Object> map){
        return "/party/realtimeArticle";
    }

    /**
     * @author  王宇
     * @date 2018/7/28
     * @description  政治思想建设
     */
    @RequestMapping("/politicalarticle")
    public String politicalarticle(Map<String,Object> map){


        return "/party/politicalarticle";
    }

    /**
     * @author  王宇
     * @date 2018/7/28
     * @description  公告
     */
    @RequestMapping("/notice")
    public String notice(Map<String,Object> map){

        return "/party/notice";
    }

    /**
     * @author  王宇
     * @date 2018/8/6
     * @description  查看入党申请书
     */
    @RequestMapping("/applybook")
    public String applybook(){
        return "/party/fore/pdf";
    }

    /**
     * @author  王宇
     * @date 2018/8/8
     * @description  后台管理
     */
    @RequestMapping("/admin")
    public String admin(){
        return "/party/fore/index";
    }

    @RequestMapping("/need")
    public String need(){
        return "/party/need";
    }
}

